# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: 
pkgname=ocaml-notty
_pkgname=notty
pkgver=0.2.2_git20200516
_commit=67c602e3b32fdd6f4356c8e6b7537ff811ac14bf
pkgrel=1
pkgdesc="Declarative terminal library for OCaml"
url="https://github.com/pqwy/notty"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime ocaml-lwt ocaml-uutf ocaml-compiler-libs"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-lwt-dev ocaml-uutf-dev"
makedepends="$depends_dev dune ocaml ocaml-cppo"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/pqwy/notty/archive/$_commit/notty-$_commit.tar.gz
	ocaml-4.14-support.patch
	"
builddir="$srcdir/$_pkgname-$_commit"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
58ec06c391bb9b95add279ec20c08a33c6aeb3aa66c0fcf4994ec335075ac3e25d8ece26ac75300608c1d2d15f75ad6e8caa8dbfa4f535d683b0bd9b170c7546  ocaml-notty-0.2.2_git20200516.tar.gz
4c89e78ae0cf0f24bbb3259f31b6569f78ac130df208a573fadd1b6bbbb320fc6d357a2b119dee37a7c013d202887adf63d21a39523829e39cf52cc9a4a7041e  ocaml-4.14-support.patch
"
